<template>
  <div>
    <FormDialog class="fixed-dialog-height" :title="viewType?'查看':workOrderNum==='NULL'?'新建':'编辑'" :show.sync="visible" width="90%" :footer-show="false" @on-cancel="closeDialog">
      <InitializationForm :view-type="viewType" :form-key="formKey" :work-order-num="workOrderNum" v-on="$listeners" />
    </FormDialog>
  </div>
</template>

<script>
import { startForm } from '@neu/dcam-ui/api/workOrder'
// import forms from '../mixin/forms.js'
import InitializationForm from '@neu/dcam-ui/views/workOrder/forms/initializationForm'
import FormDialog from '@neu/biz-core/components/FormDialog'

export default {
  name: 'NewOrderForm',
  // 混入所有表单
  // mixins: [forms],
  components: {
    FormDialog,
    InitializationForm
  },
  props: {
    workOrderNum: {
      required: false,
      type: String,
      default: 'NULL'
    },
    workOrderType: {
      reuqired: true,
      type: String,
      default: ''
    },
    viewType: {
      required: false,
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      formKey: '',
      visible: true
    }
  },
  created() {
    startForm(this.workOrderType).then(res => {
      this.formKey = res.data.formKey
    })
  },
  methods: {
    closeDialog() {
      this.$emit('cancelNewOrderForm')
    }
  }
}
</script>
